/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import com.alibaba.fastjson.annotation.JSONField;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "customerdemand")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Customerdemand.findAll", query = "SELECT c FROM Customerdemand c"),
    @NamedQuery(name = "Customerdemand.findByIdcustomerdemand", query = "SELECT c FROM Customerdemand c WHERE c.idcustomerdemand = :idcustomerdemand"),
    @NamedQuery(name = "Customerdemand.findByTel", query = "SELECT c FROM Customerdemand c WHERE c.tel = :tel"),
    @NamedQuery(name = "Customerdemand.findByRequirement", query = "SELECT c FROM Customerdemand c WHERE c.requirement = :requirement"),
    @NamedQuery(name = "Customerdemand.findByReadyTime", query = "SELECT c FROM Customerdemand c WHERE c.readyTime = :readyTime"),
    @NamedQuery(name = "Customerdemand.findByDueDate", query = "SELECT c FROM Customerdemand c WHERE c.dueDate = :dueDate"),
    @NamedQuery(name = "Customerdemand.findByServiceTime", query = "SELECT c FROM Customerdemand c WHERE c.serviceTime = :serviceTime"),
    @NamedQuery(name = "Customerdemand.findByLongitude", query = "SELECT c FROM Customerdemand c WHERE c.longitude = :longitude"),
    @NamedQuery(name = "Customerdemand.findByLatitude", query = "SELECT c FROM Customerdemand c WHERE c.latitude = :latitude"),
    @NamedQuery(name = "Customerdemand.findByServicedate", query = "SELECT c FROM Customerdemand c WHERE c.servicedate = :servicedate"),
    @NamedQuery(name = "Customerdemand.findByAddress", query = "SELECT c FROM Customerdemand c WHERE c.address = :address"),
    @NamedQuery(name = "Customerdemand.findByStatus", query = "SELECT c FROM Customerdemand c WHERE c.status = :status"),
    @NamedQuery(name = "Customerdemand.findByArrivetime", query = "SELECT c FROM Customerdemand c WHERE c.arrivetime = :arrivetime")})
public class Customerdemand implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idcustomerdemand")
    private Integer idcustomerdemand;
    @Size(max = 20)
    @Column(name = "tel")
    private String tel;
    @Basic(optional = false)
    @NotNull
    @Column(name = "requirement")
    private double requirement;
    @Column(name = "readyTime")
    @Temporal(TemporalType.TIME)
    private Date readyTime;
    @Column(name = "dueDate")
    @Temporal(TemporalType.TIME)
    private Date dueDate;
    @Column(name = "serviceTime")
    private Integer serviceTime;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "longitude")
    private Double longitude;
    @Column(name = "latitude")
    private Double latitude;
    @Column(name = "servicedate")
    @Temporal(TemporalType.DATE)
    private Date servicedate;
    @Size(max = 45)
    @Column(name = "address")
    private String address;
    @Column(name = "status")
    private Integer status;
    @Column(name = "arrivetime")
    @Temporal(TemporalType.TIME)
    private Date arrivetime;
    @JSONField(label = "extask")
    @JoinTable(name = "problem_customerdemand", joinColumns = {
        @JoinColumn(name = "idcustomerdemand", referencedColumnName = "idcustomerdemand")}, inverseJoinColumns = {
        @JoinColumn(name = "idproblem", referencedColumnName = "idproblem")})
    @ManyToMany
    private List<Problem> problemList;
    @JSONField(label = "extask")
    @OneToMany(mappedBy = "idcustomerdemand")
    private List<TaskCustomerdemand> taskCustomerdemandList;
    @JoinColumn(name = "idcustomer", referencedColumnName = "idcustomer")
    @ManyToOne(optional = false)
    private Customer idcustomer;

    public Customerdemand() {
    }

    public Customerdemand(Integer idcustomerdemand) {
        this.idcustomerdemand = idcustomerdemand;
    }

    public Customerdemand(Integer idcustomerdemand, double requirement) {
        this.idcustomerdemand = idcustomerdemand;
        this.requirement = requirement;
    }

    public Integer getIdcustomerdemand() {
        return idcustomerdemand;
    }

    public void setIdcustomerdemand(Integer idcustomerdemand) {
        this.idcustomerdemand = idcustomerdemand;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public double getRequirement() {
        return requirement;
    }

    public void setRequirement(double requirement) {
        this.requirement = requirement;
    }

    public Date getReadyTime() {
        return readyTime;
    }

    public void setReadyTime(Date readyTime) {
        this.readyTime = readyTime;
    }

    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    public Integer getServiceTime() {
        return serviceTime;
    }

    public void setServiceTime(Integer serviceTime) {
        this.serviceTime = serviceTime;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    public Date getServicedate() {
        return servicedate;
    }

    public void setServicedate(Date servicedate) {
        this.servicedate = servicedate;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getArrivetime() {
        return arrivetime;
    }

    public void setArrivetime(Date arrivetime) {
        this.arrivetime = arrivetime;
    }

    @XmlTransient
    public List<Problem> getProblemList() {
        return problemList;
    }

    public void setProblemList(List<Problem> problemList) {
        this.problemList = problemList;
    }

    @XmlTransient
    public List<TaskCustomerdemand> getTaskCustomerdemandList() {
        return taskCustomerdemandList;
    }

    public void setTaskCustomerdemandList(List<TaskCustomerdemand> taskCustomerdemandList) {
        this.taskCustomerdemandList = taskCustomerdemandList;
    }

    public Customer getIdcustomer() {
        return idcustomer;
    }

    public void setIdcustomer(Customer idcustomer) {
        this.idcustomer = idcustomer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcustomerdemand != null ? idcustomerdemand.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Customerdemand)) {
            return false;
        }
        Customerdemand other = (Customerdemand) object;
        if ((this.idcustomerdemand == null && other.idcustomerdemand != null) || (this.idcustomerdemand != null && !this.idcustomerdemand.equals(other.idcustomerdemand))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.Customerdemand[ idcustomerdemand=" + idcustomerdemand + " ]";
    }
    
}
